/**
 * CommonQuestion 业务逻辑实现类
 * @author yanwl
 * @date 2014-08-22
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.CommonQuestion;
import com.chnbst.bstyun.service.CommonQuestionService;

@Transactional
@Service
public class CommonQuestionServiceImpl extends BaseService implements CommonQuestionService {
	
	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(CommonQuestionServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.CommonQuestionMapper";
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean deleteCommonQuestion(Integer commonQuestionId) {
		return DaoHelper.delete(nameSpace, "deleteCommonQuestion", commonQuestionId);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertCommonQuestion(CommonQuestion commonQuestion) {
		return DaoHelper.insert(nameSpace, "insertCommonQuestion", commonQuestion);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateCommonQuestion(CommonQuestion commonQuestion) {
		return DaoHelper.update(nameSpace, "updateCommonQuestion", commonQuestion);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public CommonQuestion selectCommonQuestionByCommonQuestionId(Integer commonQuestionId) {
		return (CommonQuestion)DaoHelper.query(nameSpace, "selectCommonQuestionByCommonQuestionId", commonQuestionId);
	}
	
	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<CommonQuestion> selectCommonQuestions(Map<String, Object> map) {
		return (List<CommonQuestion>)DaoHelper.list(nameSpace, "selectCommonQuestions", map);
	}

	@Override
	public int selectCommonQuestionCount() {
		return DaoHelper.count(nameSpace, "selectCommonQuestionCount", null);
	}

	@Override
	public CommonQuestion selectQuestionByTitle(String title) {
		// TODO Auto-generated method stub
		return (CommonQuestion)DaoHelper.query(nameSpace, "commonQuestionByTitle", title);
	}
}
